<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Vue组件data为什么必须是个函数而Vue的根实例则没有此限制</title>
  <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>

<div id="app">

</div>

<script>
Vue.component('comp', {
  template: `<div @click="counter++">{{counter}}</div>`,
  data:{
    counter:1
  }
})
let vm = new Vue({
  el: '#app',
  data: {},
  created() {
  },
  mounted() {
  },
  methods: {}
})
</script>
</body>
</html>
